<template>
  <div id="bing1" style="height: 100%; width: 100%;"></div>
</template>

<script>
import request from "../utils/request";

export default {
  name: "Test-bing",
  data() {
    return {
      dataList: "",
      heal: "",
      nowConfirm: "",
    };
  },
  methods: {
    getData() {
      setInterval(() => {
        request.get("/cov/f4").then((res) => {
          this.heal = res[0].heal;
          this.nowConfirm = res[0].nowConfirm;
          this.initEcharts();
        });
      }, 3000);
    },
    initEcharts() {
      var chartDom = document.getElementById("bing1");
      var myChart = echarts.init(chartDom);
      var option;

      option = {
        title: {
          text: "治愈比例",
          left: "left",
          textStyle: {
            color: "#fff",
          },
        },
        tooltip: {
          trigger: "item",
        },
        legend: {
          top: "5%",
          left: "right",
          textStyle: {
            color: "#fff"
          }
        },
        series: [
          {
            name: "Access From",
            type: "pie",
            radius: ["40%", "70%"],
            avoidLabelOverlap: false,
            itemStyle: {
              borderRadius: 10,
              borderColor: "#fff",
              borderWidth: 2,
            },
            label: {
              show: false,
              position: "center",
            },
            emphasis: {
              label: {
                show: true,
                fontSize: "10",
                fontWeight: "bold",
              },
            },
            labelLine: {
              show: false,
            },
            data: [
              { value: this.nowConfirm, name: "累计确诊人数" },
              { value: this.heal, name: "目前治愈人数" },
            ],
            textStyle: {
              color: "#fff",
            },
          },
        ],
      };

      myChart.setOption(option);
    },
  },
  mounted() {
    this.getData();
  },
};
</script>

<style scoped>
</style>
